package com.fen.demo020;

import lombok.ToString;

/**
 * @author lrf
 */
@ToString
public class Singer {

    private static final String DEFAULT_NAME = "Default Name";

    private String name;

    private int age = Integer.MIN_VALUE;

    public void setName(String name) {
        this.name = name;
    }

    public void setAge(int age) {
        this.age = age;
    }


    public void init() {

        System.out.println("Initializing bean");
        if (name == null) {
            System.out.println("Using default name");
            name = DEFAULT_NAME;

        }
        if (age == Integer.MIN_VALUE) {
            System.out.println("age = " + age);
            throw new IllegalArgumentException("You must set the age property of any beans of type " + Singer.class);
        }
    }

}